<template>
  <van-sidebar class="left" v-model="leftBarCurrent">
    <van-sidebar-item
      v-for="item of list"
      :key="item.id"
      :title="item.mallCateforyName"
    />
  </van-sidebar>
</template>
<script setup>
import { onMounted, reactive, ref, watchEffect } from "vue";
import { useLeftBar } from "../utils/useLeftBar.js";

let leftBarCurrent = ref(0); //左侧导航栏索引值
let list = ref([]); //左侧列表

const emit = defineEmits(["leftBarCurrentEmit"]);

watchEffect(() => {
  let current = leftBarCurrent;
  // console.log(current.value);
  emit("leftBarCurrentEmit", current);
});

onMounted(async () => {
  let { leftBarList } = await useLeftBar();
  list.value = leftBarList.value;
});
</script>
